<%@page import="com.solution.common.config.PublicConfig"%>
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<c:set var="rootPath" value="<%=PublicConfig.ROOT_PATH%>" />
<c:set var="imgRootPath" value="<%=PublicConfig.IMG_ROOT_URL%>" />

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>用户编辑</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="${rootPath}/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="${rootPath}/layuiadmin/style/admin.css" media="all">
<script type="text/javascript">
	var rootPath = '${rootPath}';
	var imgRootPath = '${imgRootPath}';
</script>
</head>
<body>

	<div class="layui-fluid" style="padding:0px;">
    	<div class="layui-card">
      		<div class="layui-card-body" style="padding: 15px;">
				<div class="layui-form" lay-filter="layuiadmin-form-useradmin" id="layuiadmin-form-useradmin" style="padding: 20px 0 0 0;">
					<input type="hidden" name="id" value="${user.id}"/>
					<div class="layui-form-item">
						<label class="layui-form-label">登录账号</label>
						<div class="layui-input-inline">
							<input type="text" name="userCode" lay-verify="required" placeholder="请输入登录账号" 
									autocomplete="off" class="layui-input" value= "${user.userCode }">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">用户姓名(昵称)</label>
						<div class="layui-input-inline">
							<input type="text" name="userName" lay-verify="required" placeholder="请输入用户姓名(昵称)" 
								autocomplete="off" class="layui-input" value="${user.userName }">
						</div>
					</div>
					<div class="layui-form-item" lay-filter="sex">
						<label class="layui-form-label">性别</label>
						<div class="layui-input-inline">
							<input type="radio" name="userGender" value="1" title="男" ${user.userGender == '1' ? 'checked' : '' }> 
							<input type="radio" name="userGender" value="0" title="女" ${user.userGender == '0' ? 'checked' : '' }>
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">手机号码</label>
						<div class="layui-input-inline">
							<input type="text" name="mobile" lay-verify="mobile" placeholder="请输入手机号码" 
								autocomplete="off" class="layui-input" value="${user.mobile }">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">邮箱</label>
						<div class="layui-input-inline">
							<input type="text" name="email" lay-verify="email" placeholder="请输入邮箱" 
									autocomplete="off" class="layui-input" value="${user.email}" />
						</div>
					</div>
					
					<div class="layui-form-item">
						<label class="layui-form-label">部门</label>
						<div class="layui-input-inline">
							<input type="hidden" id="org_id" name="orgId" value="${user.orgId}"/> 
							<input type="text" id="pop_org_name" readonly="readonly" value="${user.orgName}" placeholder="请选择部门" autocomplete="off" class="layui-input">
						</div>
					</div>
					
					<div class="layui-form-item">
						<label class="layui-form-label">头像</label>
						<div class="layui-input-inline" style="width:100px;" id="img_con">
							<c:if test="${user.path != null}">
								<img alt="" src="${imgRootPath}${user.path}" style="height:70px;width:70px;">
							</c:if>
						</div>
						<div class="layui-input-inline">
							<input type="hidden" id="path" name="path" value= "${user.path}"  />
							<button style="float: left;" type="button" class="layui-btn" id="upload_head_image">上传图片</button>
						</div>
						
					</div>
					
					<div class="layui-form-item layui-hide">
						<input type="button" lay-submit lay-filter="user_form_submit" id="user_form_submit" value="确认">
					</div>
				</div>
				
			</div>
		</div>
	</div>
	
	<script src="${rootPath}/layuiadmin/layui/layui.all.js"></script>
	
	<script style="text/javascript">
		;!function(){
			var layer = layui.layer;
			var form = layui.form;
			var $ = layui.$;
			var table = layui.table;
			var upload = layui.upload ;
			
			upload.render({
				elem: '#upload_head_image',
				url: rootPath + "/uploadFile/uploadOneFile",
				accept: 'images',
				method: 'post',
				acceptMime: 'image/*',
				done: function(res, index ,upload){
					if(res.code == '1'){
						$("#path").val(res.filePath);
						$("#img_con").html("<img src='"+imgRootPath+res.filePath+"' style='width:70px;height:70px;' >");
					}
			    }
			});
			
			// 弹框
			$("#pop_org_name").click(function(){
				layer.open({
					title : '选择组织机构',
					type : 2,
					content : rootPath + "/org/toOrgSelector",
					btn : ['确定' , '取消'],
					yes : function(index, layero){
						// iframe 容口
						var iframeWindow = window['layui-layer-iframe'+ index]
			    		// 表单上的 lay-fitler 属性值
			            var submitID = 'btn_confirm';
			    		// 根据提交表单按钮元素
			            var submit = layero.find('iframe').contents().find('#'+ submitID);
			            //监听提交
			            iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
			            	//获取提交的字段
			              	var field = data.field;
			              	$("#org_id").val(field.id);
			              	$("#pop_org_name").val(field.name);
			              	layer.close(index); 
			            });
			            
			            submit.trigger('click');
					},
					btn2 : function(index){
						layer.close(index);
					}
				});
			});
		}();
  	</script>
  
  
</body>
</html>


